stage.set_background("winter")
sprite = codesters.Sprite("fox")
sprite.move_down(150)
stage.wait(2)
sprite.move_right(50)
def click():
sprite.say("Hello, Codester")
sprite.event_click(click)
t = codesters.Teacher()
says = t.find_function('say')
turns = t.find_function('turn_right')
defs = t.find_text('def')
try:
tval1 = stage.get_background()
except:
tval1 = "DNE"
try:
tval2 = sprite.get_image_name()
except:
tval2 = "DNE"
try:
tval3x = sprite.get_x()
tval3y = sprite.get_y()
except:
tval3x = "DNE"
tval3y = "DNE"
try:
tval4 = turns[0][1]
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "winter" or tval2 != 'fox', "Great job!")
t1.add_failure(tval2 == "DNE", "Oops! Did you delete your sprite!")
t1.add_failure(tval1 == None, "Oops! Did you delete your background?")
t1.add_failure(tval1 == 'winter' and tval2 == 'fox', "Make sure you complete Requirement #1!")
t2 = TestObjective()
t2.add_success(tval3x != 50 or tval3y != -150, "Great job!")
t2.add_failure(tval3x == "DNE" or tval3y == "DNE", "Oops! Did you delete your sprite?")
t2.add_failure(tval3x == 50 and tval3y == -150, "Make sure you complete Requirement #2!")
t3 = TestObjective()
t3.add_success(tval4 != "DNE", "Great job!")
t3.add_failure(tval4 == "DNE", "Did you add a Turn Right command?")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)